package com.winit.requirement.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.util.CollectionUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Entity
@ApiModel(value="brdRequirement",description="brdRequirement")
@Table(name = "matrix_requirements")
@DynamicUpdate
@DynamicInsert
public class BrdRequirement implements Serializable {
    @Id
    @Column(name = "req_id")
    private String reqId;
    //`需求名称
    @Column(name = "req_name")
    private String reqName;
    //需求描述
    @Column(name = "req_desc")
    private String reqDesc;
    @Column(name = "brd_id")
    private String brdId;
    @Column(name = "project_plan_id")
    private String projectPlanId;
    //状态
    @Column(name = "req_status")
    private String reqStatus;
    //工时，小时为单位
    @Column(name = "req_use_time")
    private Integer reqUseTime;

    @Column(name = "req_creater_account")
    private String reqCreaterAccount;

    @Column(name = "req_creater_realname")
    private String reqCreaterRealname;

    @Column(name = "req_update_account")
    private String reqUpdateAccount;

    @Column(name = "req_update_realname")
    private String reqUpdateRealname;

    @Column(name = "req_create_time")
    private Date reqCreateTime;

    @Column(name = "req_update_time")
    private Date reqUpdateTime;
    //需求负责人
    @Column(name = "req_charger_account")
    private String reqChargerAccount;
    @Column(name = "req_charger_realname")
    private String reqChargerRealname;
    //是否删除 0 删除 1 未删除
    @Column(name = "req_is_del")
    private String reqIsDel;

    @Column(name = "req_priority")
    private Integer reqPriority;
    //'功能概述'
    @Column(name = "req_function_desc")
    private String reqFunctionDesc;
    //'前置条件'
    @Column(name = "req_pre_condition")
    private String reqPreCondition;
    //'后置条件'
    @Column(name = "req_post_condition")
    private String reqPostCondition;
    //'数据初始化'
    @Column(name = "req_data_inition")
    private String reqDataInition;
    //'旧数据处理'
    @Column(name = "req_legacy_data_dispose")
    private String reqLegacyDataDispose;
    //'线上配置要求'
    @Column(name = "req_online_config_requirement")
    private String reqOnlineConfigRequirement;

    @Transient
    Map<String, String> featureNodes;

    /**brd业务线，2017-12-01新增*/
    @Transient
    private String brdBusiness;

    @Column(name = "req_no")
    private String reqNo ;

    @Transient
    Map<String, String> featureDesc;


    @Column(name = "req_note")
    private String reqNote;


    @Column(name = "issues")
    private String issues;
    @Column(name = "product_line_id")
    private String productLineId;

    /**
     * feature id 以逗号分隔
     */
    @Column(name = "features")
    private String features;

    @Column(name = "flows")
    private String flows;

    @Column(name="config_id")
    private String configId;


    public String getFlows() {
        return flows;
    }

    public void setFlows(String flows) {
        this.flows = flows;
    }

    public String getFeatures() {
        return features;
    }

    public void setFeatures(String features) {
        this.features = features;
    }

    //    @Transient
//    private List<String> issuesIds;


    public Map<String, String> getFeatureDesc() {
        return featureDesc;
    }

    public void setFeatureDesc(Map<String, String> featureDesc) {
        this.featureDesc = featureDesc;
    }

    @ApiModelProperty(hidden = true)
    @Transient
    private String projectPlanName;

    @ApiModelProperty(hidden = true)
    @Transient
    private String brdName;

    /**
     * 是否创建同名称项目计划
     * 0-否，1-是
     */
    @Transient
    private String newPlan;
    /**
     * 创建同名称项目计划使用的项目id
     */
    @Transient
    private String projectFlag;
    /**
     * saveBrdRequirements当创建同名称项目时这个tokenid是必须的
     */
    @Transient
    private String tokenId;


    public String getProjectPlanName() {
        return projectPlanName;
    }

    public void setProjectPlanName(String projectPlanName) {
        this.projectPlanName = projectPlanName;
    }

    public String getBrdName() {
        return brdName;
    }

    public void setBrdName(String brdName) {
        this.brdName = brdName;
    }

    public String getReqId() {
        return reqId;
    }

    public void setReqId(String reqId) {
        this.reqId = reqId;
    }

    public String getReqName() {
        return reqName;
    }

    public void setReqName(String reqName) {
        this.reqName = reqName;
    }

    public String getReqDesc() {
        return reqDesc;
    }

    public void setReqDesc(String reqDesc) {
        this.reqDesc = reqDesc;
    }

    public String getBrdId() {
        return brdId;
    }

    public void setBrdId(String brdId) {
        this.brdId = brdId;
    }

    public String getProjectPlanId() {
        return projectPlanId;
    }

    public void setProjectPlanId(String projectPlanId) {
        this.projectPlanId = projectPlanId;
    }

    public String getReqStatus() {
        return reqStatus;
    }

    public void setReqStatus(String reqStatus) {
        this.reqStatus = reqStatus;
    }


    public String getReqCreaterAccount() {
        return reqCreaterAccount;
    }

    public void setReqCreaterAccount(String reqCreaterAccount) {
        this.reqCreaterAccount = reqCreaterAccount;
    }

    public String getReqCreaterRealname() {
        return reqCreaterRealname;
    }

    public void setReqCreaterRealname(String reqCreaterRealname) {
        this.reqCreaterRealname = reqCreaterRealname;
    }

    public Integer getReqUseTime() {
        return reqUseTime;
    }

    public void setReqUseTime(Integer reqUseTime) {
        this.reqUseTime = reqUseTime;
    }

    public Date getReqCreateTime() {
        return reqCreateTime;
    }

    public void setReqCreateTime(Date reqCreateTime) {
        this.reqCreateTime = reqCreateTime;
    }

    public String getReqChargerAccount() {
        return reqChargerAccount;
    }

    public void setReqChargerAccount(String reqChargerAccount) {
        this.reqChargerAccount = reqChargerAccount;
    }

    public String getReqChargerRealname() {
        return reqChargerRealname;
    }

    public void setReqChargerRealname(String reqChargerRealname) {
        this.reqChargerRealname = reqChargerRealname;
    }

    public String getReqIsDel() {
        return reqIsDel;
    }

    public void setReqIsDel(String reqIsDel) {
        this.reqIsDel = reqIsDel;
    }

    public Map<String, String> getFeatureNodes() {
        return featureNodes;
    }

    public void setFeatureNodes(Map<String, String> featureNodes) {
        this.featureNodes = featureNodes;
    }

    public Integer getReqPriority() {
        return reqPriority;
    }

    public void setReqPriority(Integer reqPriority) {
        this.reqPriority = reqPriority;
    }

    public String getReqFunctionDesc() {
        return reqFunctionDesc;
    }

    public void setReqFunctionDesc(String reqFunctionDesc) {
        this.reqFunctionDesc = reqFunctionDesc;
    }

    public String getReqPreCondition() {
        return reqPreCondition;
    }

    public void setReqPreCondition(String reqPreCondition) {
        this.reqPreCondition = reqPreCondition;
    }

    public String getReqDataInition() {
        return reqDataInition;
    }

    public void setReqDataInition(String reqDataInition) {
        this.reqDataInition = reqDataInition;
    }

    public String getReqLegacyDataDispose() {
        return reqLegacyDataDispose;
    }

    public void setReqLegacyDataDispose(String reqLegacyDataDispose) {
        this.reqLegacyDataDispose = reqLegacyDataDispose;
    }

    public String getReqOnlineConfigRequirement() {
        return reqOnlineConfigRequirement;
    }

    public void setReqOnlineConfigRequirement(String reqOnlineConfigRequirement) {
        this.reqOnlineConfigRequirement = reqOnlineConfigRequirement;
    }

    public String getReqPostCondition() {
        return reqPostCondition;
    }

    public void setReqPostCondition(String reqPostCondition) {
        this.reqPostCondition = reqPostCondition;
    }

    public String getBrdBusiness() {
        return brdBusiness;
    }

    public void setBrdBusiness(String brdBusiness) {
        this.brdBusiness = brdBusiness;
    }

    public String getReqNo() {
        return reqNo;
    }

    public void setReqNo(String reqNo) {
        this.reqNo = reqNo;
    }

    public String getReqNote() {
        return reqNote;
    }

    public void setReqNote(String reqNote) {
        this.reqNote = reqNote;
    }

    public String getIssues() {
        return issues;
    }

    public void setIssues(String issues) {
        this.issues = issues;
//        if (!StringUtils.isEmpty(issues)){
//            issuesIds = new ArrayList<>();
////            issuesIds = Arrays.asList(issues.split(","));
//            issuesIds.addAll(Arrays.asList(issues.split(",")));
//        }
    }

    public String getProductLineId() {
        return productLineId;
    }

    public void setProductLineId(String productLineId) {
        this.productLineId = productLineId;
    }

    public String getNewPlan() {
        return newPlan;
    }

    public void setNewPlan(String newPlan) {
        this.newPlan = newPlan;
    }

    public String getProjectFlag() {
        return projectFlag;
    }

    public void setProjectFlag(String projectFlag) {
        this.projectFlag = projectFlag;
    }

    public String getTokenId() {
        return tokenId;
    }

    public void setTokenId(String tokenId) {
        this.tokenId = tokenId;
    }

    //    public List<String> getIssuesIds() {
//        return issuesIds;
//    }
//
//    public void setIssuesIds(List<String> issuesIds) {
//        this.issuesIds = issuesIds;
//    }

    public static String getIssuesByList(List<String> lst){
        if (null == lst){
            return null;
        }
        if (CollectionUtils.isEmpty(lst)){
            return "";
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (String temp : lst){
            stringBuilder.append(temp).append(",");
        }
        return stringBuilder.toString().substring(0, stringBuilder.length() - 1);
    }


    public String getReqUpdateAccount() {
        return reqUpdateAccount;
    }

    public void setReqUpdateAccount(String reqUpdateAccount) {
        this.reqUpdateAccount = reqUpdateAccount;
    }

    public String getReqUpdateRealname() {
        return reqUpdateRealname;
    }

    public void setReqUpdateRealname(String reqUpdateRealname) {
        this.reqUpdateRealname = reqUpdateRealname;
    }

    public Date getReqUpdateTime() {
        return reqUpdateTime;
    }

    public void setReqUpdateTime(Date reqUpdateTime) {
        this.reqUpdateTime = reqUpdateTime;
    }

    public String getConfigId() {
        return configId;
    }

    public void setConfigId(String configId) {
        this.configId = configId;
    }
}
